package com.order.controller;

import com.order.dao.entity.OrderInfo;
import com.order.service.OrderService;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class OrderController {

    @Autowired
    OrderService orderService;
    @Autowired
    StringRedisTemplate redisTemplate;

    @RequestMapping("submitOrder/{commodity}")
    public Integer submitOrder(@PathVariable Integer commodity){

        return orderService.submitOrder(commodity);
    }

    @RequestMapping("pay/{id}")
    public Integer pay(@PathVariable Integer id){
        return orderService.pay(id);
    }

    @RequestMapping("/stock")
    public Integer stock(){
        return Integer.valueOf(redisTemplate.opsForValue().get("num"));
    }

}
